---
title: "Table A.9"
output: 
---

# Table A.9

# Who's to Blame? Postconflict Violence and Public Attitudes Towards Peace Agreements
# Wyer, Frank. 

#clear environment
```{r clear environment}
rm(list = ls())
```

# uncomment and set working directory to replication archive
# setwd("~/blame_replication")

# Uncomment to install packages if necessary
# install.packages("tidyverse")
# install.packages("estimatr")
# install.packages("texreg")

#load packages
```{r}
library(tidyverse)
library(estimatr)
library(texreg)
```

#read in data
```{r}
survey_clean <- read.csv("survey_clean.csv")
```

#summarise attentiveness variable
```{r}
#Q62: scale from 1 (very inattentive) to 6 (very attentive)
survey_clean %>% group_by(Q62) %>% count()
```

#estimate models dropping least attentive respondents (lowest attention score)
```{r drop totally inattentive}
eln_drop1la <- lm_lin(formula = eln_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean %>% filter(Q62 != 1), alpha = .05)

accords_drop1la <- lm_lin(formula = accords_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean %>% filter(Q62 != 1), alpha = .05)

dissident_drop1la <- lm_lin(dissident_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean %>% filter(Q62 != 1), alpha = .05)

index_drop1la <- lm_lin(outcomes_zscale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean %>% filter(Q62 != 1), alpha = .05)
```

#estimate models also dropping somewhat inattentive respondents (lowest and second-lowest attention scores)
```{r drop somewhat inattentive}
eln_drop3la <- lm_lin(formula = eln_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean %>% filter(Q62 > 3), alpha = .05)

accords_drop3la <- lm_lin(formula = accords_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean %>% filter(Q62 > 3), alpha = .05)

dissident_drop3la <- lm_lin(dissident_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean %>% filter(Q62 > 3), alpha = .05)

index_drop3la <- lm_lin(outcomes_zscale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean %>% filter(Q62 > 3), alpha = .05)
```

#Appendix Table for models dropping inattentive respondents
```{r generate table}
texreg(list(accords_drop1la, eln_drop1la, dissident_drop1la, index_drop1la, accords_drop3la, eln_drop3la, dissident_drop3la, index_drop3la), custom.coef.map = list("(Intercept)" = "(Intercept)", "treatmentT1" = "Postconflict Violence Treatment", "treatmentT2A" = "Government Culpability Treatment", "treatmentT2B" = "Rebel Culpability Treatment"), digits = 2, include.ci = FALSE, single.row = FALSE, include.fstatistic = FALSE, include.rmse = FALSE, include.rsquared = FALSE, include.adjrs = FALSE, include.nobs = TRUE, stars = numeric(0), float.pos = "h", caption.above	= TRUE, caption = "Treatment Effects Dropping Inattentive Respondents")
```
